home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / Hydra11s.lha / HBBS / Source / Test / DoorTester / DoorTester.c < prev    next >
C/C++ Source or Header  |  1996-06-25  |  3KB  |  127 lines

  1.  
  2. #include <exec/types.h>
  3. #include <exec/memory.h>
  4. #include <dos/dos.h>
  5. #include <clib/exec_protos.h>
  6. #include <clib/alib_protos.h>
  7. #include <clib/dos_protos.h>
  8.  
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <stdio.h>
  12. #include <ctype.h>
  13. #include <time.h>
  14.  
  15.  
  16. #ifdef __SASC
  17. int CXBRK(void) { return(0); }
  18. int _CXBRK(void) { return(0); }
  19. void chkabort(void) {}
  20. #endif
  21.  
  22. #include <HBBS/Defines.h>
  23. #include <HBBS/types.h>
  24. #include <HBBS/structures.h>
  25. #include <HBBS/hbbscommon_protos.h>
  26. #include <HBBS/hbbscommon_pragmas.h>
  27. #include <HBBS/Hbbsnode_protos.h>
  28. #include <HBBS/Hbbsnode_pragmas.h>
  29.  
  30. struct Library *HBBSCommonBase=NULL;
  31. struct Library *HBBSNodeBase=NULL;
  32.  
  33. struct BBSGlobalData *BBSGlobal=NULL;
  34. struct NodeData *N_ND=NULL;
  35. int N_NodeNum=-1;
  36.  
  37. static VOID cleanup(ULONG num)
  38. {
  39.   if (HBBSNodeBase)
  40.   {
  41.     HBBS_CleanUpDoor();
  42.     CloseLibrary (HBBSNodeBase);
  43.   }
  44.  
  45.   if (HBBSCommonBase)
  46.   {
  47.     HBBS_CleanUpCommon();
  48.     CloseLibrary (HBBSCommonBase);
  49.   }
  50.  
  51.   if (num) printf("Door Error = %d\n",num);
  52.  
  53.   exit(0);
  54. }
  55.  
  56. static VOID init(char *name)
  57. {
  58.   if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
  59.   {
  60.     cleanup(1);
  61.   }
  62.  
  63.   if (!(HBBS_InitCommon()))
  64.   {
  65.     cleanup(2);
  66.   }
  67.  
  68.   if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
  69.   {
  70.     cleanup(3);
  71.   }
  72.  
  73.   if (!(HBBS_InitDoor(N_NodeNum,name)))
  74.   {
  75.     cleanup(4);
  76.   }
  77.   SetProgramName(name);
  78. }
  79.  
  80. void DoorMain( void )
  81. {
  82.   char doorname[80],options[80];
  83.   V_ERROR error;
  84.  
  85.   DOOR_WriteText("\r\nDoor Tester 1.0\n\rEnter QUIT at the prompt to quit!");
  86.   do
  87.   {
  88.     doorname[0]=0;
  89.     DOOR_WriteText("\r\n\033[0;37mEnter Door Name To Run >\033[0;31m");
  90.  
  91.     if ((error=DOOR_GetLine(TRUE,TRUE,0))!=IN_LOSSCARRIER)
  92.     {
  93.       strNcpy(doorname,N_ND->CurrentLine,79);
  94.       if (doorname[0])
  95.       {
  96.         DOOR_WriteText("\033[0;37mEnter Options >\033[0;31m");
  97.         if ((error=DOOR_GetLine(TRUE,TRUE,0))!=IN_LOSSCARRIER)
  98.         {
  99.           DOOR_WriteText("\033[0;37m");
  100.           strNcpy(options,N_ND->CurrentLine,79);
  101.           DOOR_WriteText("\033[0;37mRunning Door...\r\n\r\n");
  102.           DOOR_SystemDoor(doorname,options);
  103.         }
  104.       }
  105.     }
  106.   } while (N_ND->OnlineStatus == OS_ONLINE && stricmp("QUIT",doorname));
  107. }
  108.  
  109. int main(int argc,char *argv[])
  110. {
  111.   if (sscanf(argv[1],"%d",&N_NodeNum)==0)
  112.   {
  113.     printf("Invalid/No Paramaters for door!\n");
  114.     exit (20);
  115.   }
  116.   init("SystemDoorTester");
  117.  
  118.   if (BBSGlobal=HBBS_GimmeBBS())
  119.   {
  120.     if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
  121.     {
  122.       DoorMain();
  123.     }
  124.   }
  125.   cleanup(0);
  126. }
  127.